package com.huiquan.foundation.util;

import net.sf.json.JSONObject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author lichao email:lichao@witspring.com
 * @Description:
 * @Date 2017/11/8 10:21
 * @since Ver V
 */
public class RequestUtils {

    public static void constructResponse(HttpServletRequest req, HttpServletResponse resp, Object data) throws IOException {
        // 设置返回编码格式
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=utf-8");
        String result = JSONObject.fromObject(data).toString();
        resp.getWriter().write(result);
    }
}
